package dijjer.io.xfer.http.handlers;

import java.io.Reader;
import java.net.HttpURLConnection;
import java.util.HashMap;
import java.util.Map;
import dijjer.io.xfer.http.HTTPResponse;
import dijjer.io.xfer.http.PageHandler;

public class TemplatePageHandler extends PageHandler {

	public static final String VERSION = "$Id: TemplatePageHandler.java 2 2008-03-21 14:33:03Z ian.clarke $";

	private final Map _fields = new HashMap();

	public TemplatePageHandler(String template)
	{
		_template = template;
	}

	private final String _template;

	public HTTPResponse handleRequest(String method, String url, Map params, Map headers, Reader additional)
	{
		TemplateResponse response
			= new TemplateResponse(_template, HttpURLConnection.HTTP_OK, "OK", "text/html");
		response.setPageFields(_fields);
		return response;
	}

	public void setTemplateField(String name, String value) {
		_fields.put(name, value);
	}

}

